package com.fourthGroup.feign;

import com.fourthGroup.fallback.OrderClientFallbackFactory;
import com.fourthGroup.model.Order;
import com.fourthGroup.model.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@FeignClient(value = "service-order", fallbackFactory = OrderClientFallbackFactory.class)
public interface OrderClient {
    
    /**
     * 下订单
     */
    @RequestMapping("/order/product/{pid}")
    Order createOrder(@PathVariable("pid") Integer pid);
    
    /**
     * 查询订单
     */
    @RequestMapping("/order/query/{oid}")
    Order queryOrderById(@PathVariable("oid") Long oid);
    
    /**
     * 查询订单的所有信息（包括用户信息）
     */
    @RequestMapping("/order/queryall/{oid}")
    Map<String, Object> queryOrderForAllById(@PathVariable("oid") Long oid);
    
    /**
     * 更新订单状态
     */
    @RequestMapping("/order/updatestatus/{oid}")
    Order updateOrderStatusById(@PathVariable("oid") Long oid);
    
    /**
     * 查询订单对应的商品信息
     */
    @RequestMapping("/order/queryproduct/{oid}")
    Product queryProductById(@PathVariable("oid") Long oid);
}